package com.imooc.mymall.exception;

import lombok.Getter;

/**
 * <h1>业务类异常</h1>
 * @Author: crowsjian
 * @Date: 2020/7/13 21:52
 */
public class BusinessException extends RuntimeException {
    /*异常编号*/
    @Getter
    private final String code;

    /**
     * <h2>根据枚举构造业务类异常</h2>
     * @param errorCodeEnum
     */
    public BusinessException(ErrorCodeEnum errorCodeEnum){
        super(errorCodeEnum.getMessage());
        this.code = errorCodeEnum.getCode();
    }

    /**
     * <h2>自定义消息体构造业务类异常</h2>
     * @param errorCodeEnum
     * @param message
     */
    public BusinessException(ErrorCodeEnum errorCodeEnum,String message){
        super(message);
        this.code = errorCodeEnum.getCode();
    }

    /**
     * <h2>根据异常构造业务类异常</h2>
     * @param errorCodeEnum
     * @param cause
     */
    public BusinessException(ErrorCodeEnum errorCodeEnum,Throwable cause){
        super(cause);
        this.code = errorCodeEnum.getCode();
    }

}
